﻿@model TidyBlog.Entity.Setup

@{
	ViewBag.Title = "网站设置";
	Layout = "~/Views/Shared/_ManageLayout.cshtml";
}
<form action="@Url.Action("Edit")" method="post">
	<table class="cols-2">
		<thead>
			<tr><th colspan="4" class="alignLeft">@ViewBag.Title</th></tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="4" class="buttons">
					<input type="submit" value="提 交" />
					<input type="reset" value="恢 复" />
				</td>
			</tr>
		</tfoot>
		<tbody>
			<tr class="cols-4">
				<th><label for="SiteName">网站名：</label></th>
				<td>
					<input id="SiteName" name="SiteName" type="text" maxlength="50" size="22" value="@Model.SiteName" />
					<span class="required">*</span>
				</td>
				<th><label for="SiteDomain">网站域名：</label></th>
				<td>
					<input id="SiteDomain" name="SiteDomain" type="text" maxlength="30" size="22" value="@Model.SiteDomain" />
					<span class="required">*</span>
				</td>
			</tr>
			<tr class="cols-4">
				<th><label for="IsOpen">网站开关：</label></th>
				<td>
					<select name="IsOpen" id="isOpen">
						<option value="0"@Html.Raw(Model.IsOpen == 0 ? " selected=\"selected\"" : String.Empty)>关闭</option>
						<option value="1"@Html.Raw(Model.IsOpen == 1 ? " selected=\"selected\"" : String.Empty)>开放</option>
					</select>
				</td>
				<th><label for="CommentLimit">评论开关：</label></th>
				<td>
					<select name="CommentLimit" id="CommentLimit">
						<option value="0"@Html.Raw(Model.CommentLimit == 0 ? " selected=\"selected\"" : String.Empty)>关闭</option>
						<option value="1"@Html.Raw(Model.CommentLimit == 1 ? " selected=\"selected\"" : String.Empty)>需审核</option>
						<option value="2"@Html.Raw(Model.CommentLimit == 2 ? " selected=\"selected\"" : String.Empty)>完全开放</option>
					</select>
				</td>
			</tr>
			<tr>
				<th><label for="CloseReason">关站原因：</label></th>
				<td colspan="3"><textarea id="CloseReason" name="CloseReason" cols="60" rows="3">@Model.CloseReason</textarea></td>
			</tr>
			<tr class="cols-4">
				<th><label for="Keywords">关键字：</label></th>
				<td><input id="Keywords" name="Keywords" type="text" maxlength="255" size="30" value="@Model.Keywords" /></td>
				<th><label for="TimeZone">时区：</label></th>
				<td>
					<input id="TimeZone" name="TimeZone" type="text" maxlength="6" size="6" value="@Model.TimeZone" />
					<span class="required">*</span>
				</td>
			</tr>
			<tr>
				<th><label for="Description">描述：</label></th>
				<td colspan="3"><textarea id="Description" name="Description" cols="60" rows="3">@Model.Description</textarea></td>
			</tr>
			<tr class="cols-4">
				<th><label for="ForbiddenIP">禁止IP：</label></th>
				<td>
					<textarea id="ForbiddenIP" name="ForbiddenIP" cols="20" rows="5">@Model.ForbiddenIP</textarea>
					<span class="tips" style="vertical-align: bottom;">(每行一个IP)</span>
				</td>
				<th><label for="CommentInterval">评论间隔：</label></th>
				<td>
					<input id="CommentInterval" name="CommentInterval" type="text" maxlength="3" size="3" value="@Model.CommentInterval" /> 秒
					<span class="required">*</span>
					<span class="tips">(0-255, 0为不限制)</span>
				</td>
			</tr>
			<tr>
				<th>评论字数：</th>
				<td colspan="3">
					<input name="MinCommentSize" type="text" maxlength="3" size="5" value="@Model.MinCommentSize" />
					&lt;= 字数 &lt;=
					<input name="MaxCommentSize" type="text" maxlength="5" size="5" value="@Model.MaxCommentSize" />
					<span class="required">*</span>
					<span class="tips">(0-65535, 0为不限制)</span>
				</td>
			</tr>
		</tbody>
	</table>
</form>
@section Script{
<script>
require(['dom/1.0.x/', 'validator/1.0.x/', '/common/util/1.0.x/'], function($, Validator, util) {
	new Validator({
		form: $('form'),
		steps: [
			{ fields: 'SiteName', message: '网站名不能为空' },
			{ fields: "SiteDomain", message: '网站域名不能为空' },
			{ fields: 'MinCommentSize', rule: 'min:0&&max:65535', message: '最少评论字数必须为0-65535' },
			{ fields: 'MaxCommentSize', rule: 'min:0&&max:65535', message: '最大评论字数必须为0-65535' },
			{ fields: 'CommentInterval', rule: 'min:0&&max:255', message: '评论间隔必须为0-255秒' },
			{
				fields: 'MinCommentSize MaxCommentSize',
				rule: function (min, max) { return Number(max[0]) >= Number(min[0]); },
				message: '评论最大字数不能小于评论最小字数'
			}
		],
		events: {
			submiterror: util.onSubmitError
		}
	});
});
</script>
}